/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sentry;

import io.sentry.protocol.Contexts;
import io.sentry.protocol.Request;
import io.sentry.protocol.SentryId;

import java.util.List;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;

/**
 * ITransaction
 *
 * @since 2021-06-02
 **/
public interface ITransaction extends ISpan {
    /**
     * Sets transaction name.
     *
     * @param name - transaction name
     */
    void setName(@NotNull String name);

    /**
     * Returns transaction name.
     *
     * @return transaction name
     */
    @NotNull
    String getName();

    /**
     * get span list
     *
     * @return spans
     */
    @NotNull
    @TestOnly
    List<Span> getSpans();

    /**
     * Returns if transaction is sampled.
     *
     * @return is sampled
     */
    @Nullable
    Boolean isSampled();

    /**
     * Returns the latest span that is not finished.
     *
     * @return span or null if not found.
     */
    @Nullable
    Span getLatestActiveSpan();

    /**
     * Returns transaction's event id.
     *
     * @return the event id
     */
    @NotNull
    SentryId getEventId();

    /**
     * Attaches request information to the transaction.
     *
     * @param request the request
     * @deprecated use {@link Scope#setRequest(Request)}
     */
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    void setRequest(@Nullable Request request);

    /**
     * Returns the request information from the transaction
     *
     * @return the request or {@code null} if not set
     * @deprecated use {@link Scope#getRequest()}
     */
    @Nullable
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    Request getRequest();

    /**
     * Returns contexts associated with the transaction.
     *
     * @return the contexts
     * @deprecated use {@link Scope#getContexts()}
     */
    @NotNull
    @Deprecated
    @ApiStatus.ScheduledForRemoval
    Contexts getContexts();
}
